package com.ghn.cocknovel.ui.activity.myorder.vm

import android.app.Application
import android.util.Log
import androidx.lifecycle.MutableLiveData
import com.example.basemodel.base.BaseViewModel
import com.ghn.cocknovel.net.DataService
import com.ghn.cocknovel.ui.activity.main.vm.MainViewModel
import com.kt.NetworkModel.bean.QuerydrivertranstiorBean
import com.kt.NetworkModel.bean.queryDriverTransitOrderListBean
import com.kt.NetworkModel.net.CallBack
import com.kt.NetworkModel.net.RxUtils

/**
 * @author 浩楠
 *
 * @date 2023/10/12-9:43.
 *
 *      _              _           _     _   ____  _             _ _
 *     / \   _ __   __| |_ __ ___ (_) __| | / ___|| |_ _   _  __| (_) ___
 *    / _ \ | '_ \ / _` | '__/ _ \| |/ _` | \___ \| __| | | |/ _` | |/ _ \
 *   / ___ \| | | | (_| | | | (_) | | (_| |  ___) | |_| |_| | (_| | | (_) |
 *  /_/   \_\_| |_|\__,_|_|  \___/|_|\__,_| |____/ \__|\__,_|\__,_|_|\___/
 * @Description: TODO
 */
open class MyorderViewModel(application: Application) : BaseViewModel(application) {
    companion object {
        val TAG: String? = MainViewModel::class.simpleName
    }

    val queryDriverTransitOrder = MutableLiveData<MutableList<queryDriverTransitOrderListBean>?>()
    val queryTransitOrder = MutableLiveData<QuerydrivertranstiorBean?>()

    /**
     *  查询列表
     */
    open fun queryDriverTransitOrderList(currentPage: Int,taskId:String) {
        DataService.queryDriverTransitOrderList(currentPage,taskId).compose(RxUtils.mainSync())
            .subscribe(object : CallBack<MutableList<queryDriverTransitOrderListBean>>() {
                override fun onResult(result: MutableList<queryDriverTransitOrderListBean>?) {
                    result?.also {
                        queryDriverTransitOrder.value = it
                    }
                }
            })
    }
    /**
     *  查询详情
     */
    open fun queryTransitOrder(orderId: String) {
        DataService.queryTransitOrder(orderId).compose(RxUtils.mainSync())
            .subscribe(object : CallBack<QuerydrivertranstiorBean>() {
                override fun onResult(result: QuerydrivertranstiorBean?) {
                    result?.also {
                        queryTransitOrder.value = it
                    }
                }
            })
    }
}